<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        .mybtn{
            width: 100px;
            height: 100px;
            background: green;
        }
    </style>
    <script>
        // 等待页面数据加载完毕触发onload事件
        // window.onload = function(){
        //     var oBtn = document.getElementById("btn");
        //     alert(oBtn);
        // }
        function fnLoad(){
            var oBtn = document.getElementById("btn")
            alert(oBtn)
            oBtn.className="mybtn"
        }
    </script>
</head>
<body>
    <input type="button" value="按钮" id="btn" onclick="fnLoad()">
</body>
</html>